Skip to content

Add Schedules.get_subscriptions_by_schedule to list a schedule's subscriptions - #1873

Open
ChrisJr404 wants to merge 1 commit into
tableau:developmentfrom
ChrisJr404:schedules/get-subscriptions-by-schedule
Open

Add Schedules.get_subscriptions_by_schedule to list a schedule's subscriptions#1873
ChrisJr404 wants to merge 1 commit into
tableau:developmentfrom
ChrisJr404:schedules/get-subscriptions-by-schedule

Conversation

@ChrisJr404

Copy link
Copy Markdown

Motivation

Closes #1250. TSC wraps extract refresh tasks per schedule with get_extract_refresh_tasks(schedule_id), but there was no way to ask "which subscriptions run on this schedule?", which is what the issue asks for (monitoring the tasks in a schedule against a whitelist).

I went looking for a /schedules/{id}/subscriptions endpoint to mirror the extracts one, but the REST API doesn't have it. Subscriptions are only listable at the site level via Query Subscriptions, and each subscription already carries its schedule id. So this filters that list client side.

Behavior change

Adds one public method:

subs = server.schedules.get_subscriptions_by_schedule(schedule_id)  # -> list[SubscriptionItem]

It pages through the site subscriptions and returns the ones whose schedule_id matches, so on a busy site it costs one request per page. Nothing else changes. I put it on Schedules next to get_extract_refresh_tasks so the two task-listing calls live together. Because there's no server-side filter, this is a plain list, not a (list, PaginationItem) tuple like get(). Documented the per-page cost and the "no per-schedule endpoint" caveat in the docstring, and added a CHANGELOG entry.

Test plan

  • test_get_subscriptions_by_schedule reuses the existing subscription_get.xml asset (its two subscriptions are on different schedules) and asserts only the matching one comes back.
  • test_get_subscriptions_by_schedule_no_match asserts an unknown schedule id yields [].
  • test_get_subscriptions_by_schedule_empty_id asserts an empty id raises ValueError, matching the other schedule methods.
  • Full suite: 908 passed, 1 skipped. black --check and mypy clean.

One thing on trust rather than a regression test: I couldn't hit a live server, so the client-side-filter approach rests on the documented fact that Query Subscriptions returns every subscription with its <schedule id=...>, which the existing SubscriptionItem parsing already relies on.

@salesforce-cla

Copy link
Copy Markdown

Thanks for the contribution! Before we can merge this, we need @ChrisJr404 to sign the Salesforce Inc. Contributor License Agreement.

@jacalata

jacalata commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Unfortunately subscriptions look different in Tableau Server (onprem) and Tableau Cloud, and don't have a schedule id on Cloud - that just means your method won't work for Cloud. I have a fix to at least handle the different shapes cleanly in #1875, but if you could add a docstring mention that this is Server only that would probably do. I can merge in my fix afterwards and check that it responds nicely to both kinds.
Tests look good, just need CLA signed.

@jacalata jacalata left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix merge conflict (just keep both) and add a docstring saying this is Server only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FUNCTION] [List Tasks in a Schedule]

2 participants